Skip to content

Markdown flavours

Nodes render to the Markdown of a flavour. The default flavour, material, is Markdown for Material for MkDocs / Zensical, using Python-Markdown / PyMdown extensions (admonitions, tabs, attribute lists, ...). The github flavour produces GitHub flavoured Markdown for READMEs, issues and wikis: alerts, <details> blocks, <kbd> and plain fenced code. The mdbook flavour is the GitHub flavour for mdBook (optionally with mdbook-admonish admonitions), the myst flavour the GitHub flavour with MyST directives (admonitions, dropdowns, tab sets, {code-block}) for Sphinx.

import mknodes as mk

node = mk.MkAdmonition("Careful!", typ="warning")
await node.to_markdown()  # Material (default)
await node.to_markdown(flavor="github")  # > [!WARNING] ...

A whole site can be generated in a flavour with the CLI. The markdown engine writes plain Markdown files plus a SUMMARY.md nav and defaults to github:

mknodes generate --engine markdown --flavor github --generated-dir build/markdown

Each engine has a default flavour, see Site engines. The flavour can also be set with the flavor setting (see Configuration) or passed to DocBuilder. The renderer classes are documented in Core API / Rendering.

Side by side

Each node is shown as rendered on this site, followed by its Markdown in both flavours.

Admonition

Careful

Content with Markdown.

Material
!!! warning "Careful"
    Content with **Markdown**.
GitHub
> [!WARNING]
> **Careful**
>
> Content with **Markdown**.

Collapsible admonition

Click me

Hidden until clicked.

Material
??? info "Click me"
    Hidden until clicked.
GitHub
<details>
<summary>Click me</summary>

Hidden until clicked.

</details>

Tabs

import mknodes as mk
pip install mknodes
Material
===! "Python"
    ``` {.py }
    import mknodes as mk
    ```

=== "Shell"
    ``` {.bash }
    pip install mknodes
    ```
GitHub
<details open>
<summary>Python</summary>

```py
import mknodes as mk
```

</details>

<details>
<summary>Shell</summary>

```bash
pip install mknodes
```

</details>

Code block with title

build.py
import mknodes as mk

nav = mk.MkNav()
Material
``` {.py  title='build.py'}
import mknodes as mk

nav = mk.MkNav()
```
GitHub
**build.py**

```py
import mknodes as mk

nav = mk.MkNav()
```

Keys

Ctrl+Alt+Del

Material
++ctrl+alt+del++
GitHub
<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Del</kbd>

Details block

More info

Some details.

Material
/// details | More info
    type: tip

Some details.
///
GitHub
<details>
<summary>More info</summary>

Some details.

</details>

Definition list

MkNav
A section of the documentation.
MkPage
A page of the documentation.
Material
MkNav
:   A section of the documentation.
MkPage
:   A page of the documentation.
GitHub
<dl>
<dt>MkNav</dt>
<dd>

A section of the documentation.

</dd>
<dt>MkPage</dt>
<dd>

A page of the documentation.

</dd>
</dl>

Critic markup

Inserted text

Material


Inserted text


GitHub
<ins>

Inserted text

</ins>

Progress bar

60%

Material
[=60% "60%"]
GitHub
`██████░░░░` 60%

:mdi-github: Repository

Material
[:mdi-github: Repository](https://github.com/phil65/mknodes)
GitHub
[<img src="https://api.iconify.design/mdi/github.svg?height=16" alt="github"> Repository](https://github.com/phil65/mknodes)

Material badge

:mdi-tag: 4.1.0

Material
<span class="md-typeset mdx-badge">
  <span class="mdx-badge__icon">:mdi-tag:</span>
  <span class="mdx-badge__text">4.1.0</span>
</span>
GitHub
<img src="https://api.iconify.design/mdi/tag.svg?height=16" alt="tag"> <code>4.1.0</code>

Docstrings

mknodes.rendering.github.alert

alert(typ: str, text: str, title: str | None = None) -> str

Return a GitHub alert block (> [!NOTE]).

Material
::: mknodes.rendering.github.alert
    options:
      heading_level: 4
      show_root_heading: True
GitHub
#### <a id="mknodes.rendering.github.alert"></a>`mknodes.rendering.github.alert`

```python
def alert(typ: str, text: str, title: str | None = None) -> str
```

Return a GitHub alert block (`> [!NOTE]`).

GitHub rules

How the github flavour renders each node. A node either has a rule (a render function registered with GithubRenderer.rule, also used for subclasses which don't render themselves), an [output.github] template in its node file, or renders its default Markdown, the same as in the material flavour. That is fine for plain Markdown (text, tables, lists); output that needs Markdown extensions (last column) may not display on GitHub. Containers rendering their default Markdown still render their children in the GitHub flavour, and hand-written Material admonitions / tabs in page text get converted.

Node GitHub output Details Extensions of the Material output
MkAdmonition Rule admonition, pymdownx.details, pymdownx.superfences
MkAnnotations Default pymdownx.superfences
MkBadge Rule A shields.io badge image (GitHub drops inline SVG).
MkBinaryImage Template of MkImage [output.github] in the node file
MkBlock Rule Unknown PyMdown blocks: keep the content, drop the block.
MkBlockQuote Default
MkCard Default
MkChangelog Default
MkClassDiagram Rule of MkCode Fenced code block with plain language info string (no attributes). pymdownx.superfences
MkClassTable Default tables
MkCliDoc Default
MkCode Rule Fenced code block with plain language info string (no attributes). pymdownx.highlight, pymdownx.superfences
MkCodeOfConduct Default
MkCommandOutput Default
MkCommentedCode Default
MkCommitConventions Default
MkCompactAdmonition Rule
MkConfigSetting Default
MkContainer Default
MkCritic Rule pymdownx.critic
MkDataClassInfo Default
MkDefinitionList Rule def_list
MkDependencyGroups Default tables
MkDependencyTable Default tables
MkDetailsBlock Rule pymdownx.blocks.details
MkDevEnvSetup Default
MkDevTools Default
MkDiagram Rule of MkCode Fenced code block with plain language info string (no attributes). pymdownx.superfences
MkDocStrings Rule API docs rendered from Griffe (GitHub has no mkdocstrings).
MkFootNotes Default footnotes
MkHeader Default
MkHtmlBlock Rule The element itself (/// html | picture -> <picture>...</picture>). pymdownx.blocks.html
MkHtmlTable Rule HTML table with unescaped Markdown cells (Material: <table markdown="1">).
MkIFrame Default
MkIcon Rule
MkImage Template [output.github] in the node file
MkImageCompare Default
MkImageSlideshow Default
MkInclude Default
MkInstallGuide Default
MkJupyterLite Default
MkKeys Rule pymdownx.keys
MkLicense Default
MkLink Rule
MkList Default def_list
MkLlm Default
MkMaterialBadge Rule
MkMetadataBadges Default
MkModuleTable Default tables
MkPipDepTree Rule of MkCode Fenced code block with plain language info string (no attributes). pymdownx.superfences
MkProgressBar Rule pymdownx.progressbar
MkPyDeps Default
MkPyScript Default
MkPyodideTerminal Default
MkReprRawRendered Default
MkShields Default
MkShowcase Default
MkSpeechBubble Rule
MkTab Rule pymdownx.tabbed
MkTabBlock Rule pymdownx.blocks.tab
MkTabContainer Rule Tabs become <details> blocks, the selected (or first) one expanded.
MkTabbed Rule of MkTabContainer Tabs become <details> blocks, the selected (or first) one expanded. pymdownx.tabbed, pymdownx.superfences
MkTabbedBlocks Rule of MkTabContainer Tabs become <details> blocks, the selected (or first) one expanded. pymdownx.blocks.tab
MkTable Default tables
MkTaskList Default pymdownx.tasklist
MkTemplate Default
MkText Default
MkTimeline Default
MkTreeView Rule of MkCode Fenced code block with plain language info string (no attributes). pymdownx.highlight, pymdownx.superfences
Page info
Code for this page
mknodes.manual.nodes_section._
@nav.route.page("Markdown flavours", icon="material/language-markdown")
def _(page: mk.MkPage) -> None:
    documented = [
        *BASE_NODES,
        *IMAGE_NODES,
        *PRESENTATION_NODES,
        *DOCUMENTATION_NODES,
        *ABOUT_THE_PROJECT_NODES,
        *CONTAINER_NODES,
        *SPECIAL_NODES,
    ]
    flavors.build_page(page, documented)
Resources
Resources(css=[],
          markdown_extensions={'admonition': {},
                               'def_list': {},
                               'md_in_html': {},
                               'pymdownx.blocks.details': {},
                               'pymdownx.critic': {},
                               'pymdownx.details': {},
                               'pymdownx.highlight': {'anchor_linenums': True,
                                                      'line_spans': '__span',
                                                      'pygments_lang_class': True},
                               'pymdownx.keys': {},
                               'pymdownx.progressbar': {},
                               'pymdownx.superfences': {},
                               'pymdownx.tabbed': {},
                               'tables': {}},
          plugins=[Plugin('mkdocstrings')],
          js=[],
          assets=[Asset('progressbar_4cf9771.css'),
                  Asset('materialbadge_31c4bf6.css')],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mknodes/mknodes/src/mknodes/manual/nodes_section.py
  source_function: _
  source_line_no: 125
icon: material/language-markdown
title: Markdown flavours